/** *******************************************************************

 * Copyright (c) 2008 Jonnie Spratley. All Rights Reserved.
 * @author  Jonnie Spratley
 * @contact jonniespratley@gmail.com
 * @internal
 ******************************************************************* */
package com.jonniespratley.codegen.vo
{
	[Bindable]
	public class Field extends Object
	{
		public var name:String;
		public var type:String;
		public var nullable:String;
		public var defaultt:String;
		public var comments:String;
		public var _alias:String;
		
		public function Field( obj:Object = null )
		{
			if ( obj != null )
			{
				name = obj['Field'];
				type = obj['Type'];
				nullable = obj['Null'];
				defaultt = obj['Default'];
				comments = obj['Extra'];
			}
		}

		public function get isNullable():Boolean
		{
			var required:Boolean;

			if ( this.nullable == 'NO' )
			{
				required = false;
			} else if ( this.nullable == 'YES' )
			{
				required = true;
			}

			return required;
		}

		public function get alias():String{ return this.name.replace( this.name.charAt(0), this.name.charAt(0).toUpperCase() ); }
		public function set alias(value:String):void{ alias = value; }
		public function get label():String{ return name; }
/* 
		public var get name():String{ return _name; }
		public var get type():String{ return _type; }
		public var get nullable():String{ return _nullable; }	
		public var get defaultt():String{ return _defaultt; }	
		public var get comments():String{ return _comments; }
		
		public var set name(value:String):void{ _name = value; }	
		public var set type(value:String):void{ _type = value; }	
		public var set nullable(value:String):void{ _nullable = value; }	
		public var set defaultt(value:String):void{ _defaultt = value; }	
		public var set comments(value:String):void{ _comments = value; }	
		 */
	}
}